package framework.extension;

import framework.compress.Compress;
import framework.compress.gzip.GzipCompress;
import framework.enums.CompressTypeEnum;
import framework.enums.SerializationTypeEnum;
import framework.serialize.Serializer;
import framework.serialize.hessian.HessianSerializer;
import framework.serialize.kyro.KyroSerializer;
import framework.serialize.protobuf.ProtobufSerializer;

import java.util.HashMap;
import java.util.Map;

public class ExtensionLoader {

    private static final Map<String, Serializer> serializerMap = new HashMap<String, Serializer>(){{
        put(SerializationTypeEnum.KYRO.getName(), new KyroSerializer());
        put(SerializationTypeEnum.PROTOSTUFF.getName(), new ProtobufSerializer());
        put(SerializationTypeEnum.HESSIAN.getName(), new HessianSerializer());
    }};

    private static final Map<String, Compress> compressMap = new HashMap<String, Compress>(){{
        put(CompressTypeEnum.GZIP.getName(), new GzipCompress());
    }};

    public static Serializer getSerialize(String name) {
        return serializerMap.get(name);
    }

    public static Compress getCompress(String name) {
        return compressMap.get(name);
    }
}
